1 using UnityEngine;
2 using
System.Collections;
3 using
UnityEngine.SceneManagement;
4
5 public
class LevelManager : MonoBehaviour
6 {
7     
public float timeTillNextLevel = 0.0f;
8
9     
// Use this for initialization
10     
void Start()
11     {
12     }
13
14     
// Update is called once per frame
15     
void Update()
16     {
17
18         
if (timeTillNextLevel > 0)
19         {
20             timeTillNextLevel -= Time.deltaTime;
21             
if (timeTillNextLevel < 0)
22             {
23                 LoadNextScene();
24                 print(
"Load Next Scene");
25             }
26             
//print("Time till next level" + timeTillNextLevel);
27         }
28
29     }
30
31     
public void LoadNextScene()
32     {
33         
int currentIndex = SceneManager.GetActiveScene().buildIndex;
34         SceneManager.LoadScene(currentIndex +
1);
35     }
36
37     
public void LoadPreviousScene()
38     {
39         
int currentIndex = SceneManager.GetActiveScene().buildIndex;
40         SceneManager.LoadScene(currentIndex -
1);
41     }
42 }


Gõ tìm kiếm nhanh...